//
//  WYPayController.m
//  Boss
//
//  Created by admin on 2018/6/28.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYPayController.h"
#import "WYWallet.h"
@interface WYPayController ()

@property (strong, nonatomic) IBOutlet UIImageView *blanceImageView;

@property (strong, nonatomic) IBOutlet UIImageView *wechatImageView;

@property (strong, nonatomic) IBOutlet UIImageView *alipayImageView;

@property (nonatomic,assign)NSUInteger payTag;

@property (strong, nonatomic) IBOutlet UIButton *doneAction;

@property (strong, nonatomic) IBOutlet UILabel *blaceLabel;
@property (nonatomic,strong) WYWallet *wallet;
@end

@implementation WYPayController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.doneAction setBackgroundColor:[UIColor hexStringToColor:@"#d8593f" alpha:1.0]];
    self.payTag = 3;
    self.wechatImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.blanceImageView.image = [UIImage imageNamed:@"slelect_icon"];
    self.alipayImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self loadData];
    // Do any additional setup after loading the view from its nib.
}
-(void)loadData
{
    WEAKSELF
    [WYHttpServer getUserWalletSucessBlock:^(BOOL success, id response, NSString *errorMessage) {
        if (success) {
            weakSelf.wallet = [WYWallet getWalletModelFromJson:response[@"result"]];
            [weakSelf upDateUI];
        }
        
        
        
    }];
    
    
}
-(void)upDateUI
{
//    self.blaceLabel.attributedText = @"";
//   
//    
//
    NSString *blace = [NSString stringWithFormat:@"%.2f",self.wallet.balance.floatValue/1000.0];
    
    
    NSMutableAttributedString *aString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"(当前余额%@)",blace]];
    [aString addAttribute:NSForegroundColorAttributeName value:[UIColor hexStringToColor:@"#d8593f" alpha:1.0] range:NSMakeRange(5, blace.length)];
    [aString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15]range:NSMakeRange(5, blace.length)];
    self.blaceLabel.attributedText = aString;
}
-(void)setMoney:(NSString *)money
{
    _money = money;
    money = [NSString stringWithFormat:@"¥%@",money];
    NSMutableAttributedString *aString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"支付金额:%@",money]];
    [aString addAttribute:NSForegroundColorAttributeName value:[UIColor hexStringToColor:@"#d8593f" alpha:1.0] range:NSMakeRange(5, money.length)];
    [aString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:24]range:NSMakeRange(5, money.length)];
    self.payMoney.attributedText = aString;
    
    
//    self.payMoney.text = [NSString stringWithFormat:@"支付金额：¥%@",money];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)exitAction:(id)sender {
    if (self.exit) {
        self.exit(@"");
    }
    
}
- (IBAction)blanceAction:(id)sender {
    
    self.payTag = 3;
    self.blanceImageView.image = [UIImage imageNamed:@"slelect_icon"];
    self.wechatImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.alipayImageView.image = [UIImage imageNamed:@"normal_icon"];
    
}
- (IBAction)wechatAction:(id)sender {
    self.payTag = 2;
    self.blanceImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.wechatImageView.image = [UIImage imageNamed:@"slelect_icon"];
    self.alipayImageView.image = [UIImage imageNamed:@"normal_icon"];
    
}
- (IBAction)alpayAction:(id)sender {
    self.payTag = 1;
    self.blanceImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.wechatImageView.image = [UIImage imageNamed:@"normal_icon"];
    self.alipayImageView.image = [UIImage imageNamed:@"slelect_icon"];
    
   // self.payMoney.text = [NSString stringWithFormat:@"支付金额：¥%@",self.money];
}
- (IBAction)doneAction:(id)sender {
    if (self.complete) {
        self.complete([NSString stringWithFormat:@"%ld",self.payTag], @"");
    }
}
-(void)dealloc
{
    
}

@end
